package com.ruibang.glass.material.service.impl.rq;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.material.domain.req.rq.ATypeWaterReq;
import com.ruibang.glass.material.entity.rq.MaterialATypeWaterBottleRackManagement;
import com.ruibang.glass.material.mapper.rq.MaterialATypeWaterBottleRackManagementMapper;
import com.ruibang.glass.material.service.rq.MaterialATypeWaterBottleRackManagementService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * A型水品托架管理 服务实现类
 * </p>
 *
 * @author mameng
 * @since 2024-04-02
 */
@Service
public class MaterialATypeWaterBottleRackManagementServiceImpl extends ServiceImpl<MaterialATypeWaterBottleRackManagementMapper, MaterialATypeWaterBottleRackManagement> implements MaterialATypeWaterBottleRackManagementService {


    @Override
    public IPage<MaterialATypeWaterBottleRackManagement> getPage(ATypeWaterReq aTypeWaterReq) {
        LambdaQueryWrapper<MaterialATypeWaterBottleRackManagement> queryWrapper = Wrappers.<MaterialATypeWaterBottleRackManagement>lambdaQuery();
        if (StringUtils.isNotBlank(aTypeWaterReq.getBoundBatch())) {
            queryWrapper.like(MaterialATypeWaterBottleRackManagement::getBoundBatch, aTypeWaterReq.getBoundBatch());
        }
        if (StringUtils.isNotBlank(aTypeWaterReq.getContainerCode())) {
            queryWrapper.like(MaterialATypeWaterBottleRackManagement::getContainerCode, aTypeWaterReq.getContainerCode());
        }
        if (StringUtils.isNotBlank(aTypeWaterReq.getContainerType())) {
            queryWrapper.like(MaterialATypeWaterBottleRackManagement::getContainerType, aTypeWaterReq.getContainerType());
        }
        if (StringUtils.isNotBlank(aTypeWaterReq.getGlassType())) {
            queryWrapper.like(MaterialATypeWaterBottleRackManagement::getGlassType, aTypeWaterReq.getGlassType());
        }
        if (StringUtils.isNotBlank(aTypeWaterReq.getQualityInspectionStatus())) {
            queryWrapper.eq(MaterialATypeWaterBottleRackManagement::getQualityInspectionStatus, aTypeWaterReq.getQualityInspectionStatus());
        }
        if (StringUtils.isNotBlank(aTypeWaterReq.getStatus())) {
            queryWrapper.eq(MaterialATypeWaterBottleRackManagement::getStatus, aTypeWaterReq.getStatus());
        }
        if (StringUtils.isNotBlank(aTypeWaterReq.getWarehouseName())) {
            queryWrapper.eq(MaterialATypeWaterBottleRackManagement::getWarehouseId, aTypeWaterReq.getWarehouseName());
        }
        if (StringUtils.isNotBlank(aTypeWaterReq.getStorageLocation())) {
            queryWrapper.eq(MaterialATypeWaterBottleRackManagement::getStorageLocation, aTypeWaterReq.getStorageLocation());
        }
        if (aTypeWaterReq.getIsUsed()!=null) {
            queryWrapper.eq(MaterialATypeWaterBottleRackManagement::getIsUsed, aTypeWaterReq.getIsUsed());
        }

        Page<MaterialATypeWaterBottleRackManagement> materialWarehouseInfoPage = baseMapper.selectPage(new Page<>(aTypeWaterReq.getPageNo(), aTypeWaterReq.getPageSize()),
                queryWrapper.orderByDesc(MaterialATypeWaterBottleRackManagement::getCreateTime)
        );
        return materialWarehouseInfoPage;
    }
}
